from aicenter.models import AIIdentity, AIModel, AIRole


class AIError(Exception):
    """AI 异常类"""

    def __init__(self, reason: str):
        self._reason = reason

    @property
    def reason(self) -> str:
        """错误原因"""
        return self._reason


class AIModelRegistrationError(AIError):
    """AI 模型注册失败异常类"""

    def __init__(self, model: AIModel):
        super().__init__(
            f'AI Model Registration Error: '
            f'AI Model is `${model.name}`.'
        )
        self._model = model

    @property
    def model(self) -> AIModel:
        """AI 模型对象"""
        return self._model


class AIIdentityRegistrationError(AIError):
    """AI 身份注册失败异常类"""

    def __init__(self, model: AIModel, role: AIRole, identity: AIIdentity):
        super().__init__(
            f'AI Identity Registration Error: '
            f'Model is `${model.name}`, '
            f'Role is `${role.name}`, '
            f'Identity is `${identity.id}`.'
        )
        self._model = model
        self._role = role
        self._identity = identity

    @property
    def model(self) -> AIModel:
        """AI 模型对象"""
        return self._model

    @property
    def role(self) -> AIRole:
        """AI 角色对象"""
        return self._role

    @property
    def identity(self) -> AIIdentity:
        """AI 身份对象"""
        return self._identity
